package com.zhuiYun.project.api.order.mapper;

import com.zhuiYun.project.api.handworkDiy.model.HandworkDiyModel;
import com.zhuiYun.project.api.order.entity.Order;
import com.zhuiYun.project.api.order.model.orderModel;
import com.zhuiYun.project.common.mapper.BaseMapper;
import com.zhuiYun.project.util.pageUtil.PageRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface orderMapper  extends BaseMapper<Order> {

    /**
     * @Author 小江
     * @Description //TODO  订单全查（模糊查）
     * @Date 10:40 2023/4/4
     **/
    @Select("<script>SELECT a.*,b.nick_name AS userB,c.* ,e.status AS statusE " +
            "FROM orders a LEFT JOIN user b ON a.user_id = b.id" +
            " LEFT JOIN user_address c ON a.address_id = c.id"  +
            " LEFT JOIN pay_mode d ON a.pay_mode_id = d.id"  +
            " LEFT JOIN order_status e ON a.status_id = e.id" +
            " where a.del_flag = 0 " +
            " <when test = 'orderNumber != &quot;&quot; and orderNumber != null'>" +
            "and    a.orderNumber like '%${orderNumber}%'</when>" +
            "</script>")
    @Results({
            @Result(property="orderNumber",column="order_number"),
            @Result(property="statusId",column="status_id"),
            @Result(property="commodityAmountTotal",column="commodity_amount_total"),
            @Result(property="orderAmountTotal",column="order_amount_total"),
            @Result(property="freight",column="freight"),
            @Result(property="orderTypeId",column="order_type_id"),
            @Result(property="userId",column="user_id"),
            @Result(property="payModeId",column="pay_mode_id"),
            @Result(property="outTradeNo",column="out_trade_no"),
            @Result(property="payTime",column="pay_time"),
            @Result(property="addressId",column="address_id"),
            @Result(property="orderlogisticsId",column="orderlogistics_id"),
    })
    List<orderModel> orderList(String orderNumber, PageRequest pageResult);
}
